#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

string s;
int a[55], n;
int cnt[10];
ll dp[55][55];
ll cmb(int n, int m) {
  if (m == 0) return 1;
  if (n < m) return 0;
  if (dp[n][m]) return dp[n][m];
  return dp[n][m] = cmb(n - 1, m - 1) + cmb(n - 1, m);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s;
  for (char c : s) {
    a[++n] = c - '0';
    cnt[a[n]]++;
  }
  ll ans = 0;
  rep(i, 1, n) {  // 50 * 100 * cmb
    rep(j, 0, a[i] - 1) {
      if (!cnt[j]) continue;
      cnt[j]--;
      ll p = 1, sz = n - i;
      rep(k, 0, 9) {
        p *= cmb(sz, cnt[k]);
        sz -= cnt[k];
      }
      ans += p;
      cnt[j]++;
    }
    cnt[a[i]]--;
  }
  cout << ans;
  return 0;
}